home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 #1 / Ham Radio 2000.iso / ham2000 / tcp_ip / ka9q / kit_src / chktxt.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-09-03  |  1.0 KB  |  45 lines

  1. /*    (C) Copyright 1991 Dave Fritsche (wb8zxu), All Rights Reserved.
  2.  * 
  3.  *    Redistribution and use in source and binary forms are permitted for
  4.  *    non-commercial use, provided that the above copyright notice and this
  5.  *    paragraph are duplicated in all such forms.  THIS SOFTWARE IS PROVIDED
  6.  *    ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
  7.  *    WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND
  8.  *    FITNESS FOR A PARTICULAR PURPOSE.
  9.  */
  10. /*bdoc
  11.  *    Function "CHKTXT"
  12.  *
  13.  *    Written:  Dave Fritsche
  14.  *    Date:  July, 1987
  15.  *
  16.  *    A function to return the length of a string after truncating all
  17.  *    white space from the end.
  18.  *    Syntax:
  19.  *        length = chktxt(string)
  20.  *    Where:
  21.  *        string = The char string under consideration
  22.  *        length = Integer return of modified string length
  23.  edoc*/
  24.  
  25. #include <stdio.h>
  26. #include <ctype.h>
  27.  
  28. int chktxt(text)
  29. char text[];
  30. {
  31.     int n;
  32.  
  33.     n = strlen(text) - 1;
  34.  
  35.     while ( (n >= 0) && (isspace(text[n])) )
  36.     {
  37.         text[n] = text[n+1];
  38.         n -= 1;
  39.     }
  40.  
  41.     n = strlen(text);
  42.  
  43.     return(n);
  44. }
  45.